/*禁止左键的拖动，防止框架溢出。↓*/
/*function disableSelection(target){
    if (typeof target.onselectstart!="undefined") //IE route
        target.onselectstart=function(){return false}
    else if (typeof target.style.MozUserSelect!="undefined") //Firefox route
        target.style.MozUserSelect="none"
    else 
        target.onmousedown=function(){return false}
    target.style.cursor = "default"
    }
    var somediv=document.getElementById("prohibit_Left_drag")//要控制的元素
    disableSelection(somediv)*/
/*禁止左键的拖动，防止框架溢出。↑*/

/*树形菜单↓*/
function init() {
    if (!document.getElementById || !document.getElementsByTagName) {
        retun;
    }
    var arrayDiv = document.getElementById("levelmenu");
    if (!arrayDiv) {
        return;
    }
    var divObj = arrayDiv.getElementsByTagName("div");
    var length = divObj.length;
    var agreeDiv = new Array();
    for (var i = 0; i < length; i++) {
        if (divObj[i].className.indexOf("unit") >= 0) {
            agreeDiv.push(divObj[i]);
            divObj[i].onclick = function(event) {
                showCurrentMenu(agreeDiv, this, event);
            }
        }
    }
}

function showCurrentMenu(agreeDiv, currentObj, event) {
    if (!event) {
        event = window.event;
    }
    var eventObj = event.srcElement ? event.srcElement : event.target;
    //先隐藏所有ul
    var length = agreeDiv.length;
    for (var i = 0; i < length; i++) {
        if (eventObj.parentNode == agreeDiv[i] || eventObj.nodeName != "H5") {
            continue;
        }
        agreeDiv[i].className = "unit";
    }
    if (eventObj.nodeName == "H5") {
        if (eventObj.parentNode.className == "unit") {
            eventObj.parentNode.className = "unit current"
        } else {
            eventObj.parentNode.className = "unit"
        }
    }
}
init();


/*控制内容高度*/
function content() {
    /*
        var con = document.getElementById("css_contentDiv");
    //  var myright = document.getElementById("main-right");
        var mylevelmenu = document.getElementById("levelmenu");
        var h = document.body.offsetHeight;
        window.onresize = function(){
            var w = document.body.offsetWidth;
            var mysidebar = $(".sidebar");
            if(w <= 800){
                mysidebar.css("display","none");    
            }else{
                mysidebar.css("display","block");
            }
        }

        if(h>500){
           con.style.height = h - 165+ 'px';
    //     myright.style.height = h - 75 + 'px';    
           mylevelmenu.style.height = h - 75 + 'px';
           mylevelmenu.style.overflow = 'auto';
        }else{con.style.height ='600px'};
    */
}
content();


/*树形菜单↑*/

/*弹出窗口显示隐藏。↓*/
function remindsetUp() {
    var i = document.getElementById("windowsPop");
    i.style.display = 'block';
    if (i.style.display == 'block') {
        i.style.display = 'none';
    }
}

/*弹出窗口显示隐藏↑*/


/*表格交互样式设定↓*/

//senfe("表格名称","奇数行背景","偶数行背景","鼠标经过背景","点击后背景","经过时字色","经过后字色",开始变色的行号);
function senfe(o, a, b, c, d, e, f, g) {
    var t = document.getElementById(o).getElementsByTagName("tr");

    for (var i = g - 1; i < t.length; i++) {
        t[i].style.backgroundColor = (t[i].sectionRowIndex % 2 == 0) ? a : b;
        t[i].onclick = function() {
            if (this.x != "1") {
                this.x = "1";

                this.style.backgroundColor = d;
            } else {
                this.x = "0";
                this.style.backgroundColor = (this.sectionRowIndex % 2 == 0) ? a : b;
            }
        }
        t[i].onmouseover = function() {
            if (this.x != "1") {
                this.style.backgroundColor = c;
                this.style.color = e;
            }
        }
        t[i].onmouseout = function() {
            if (this.x != "1") {
                this.style.backgroundColor = (this.sectionRowIndex % 2 == 0) ? a : b;
                this.style.color = f;
            }
        }
    }
}
/*表格交互样式设定↑*/

/*首页框架右边栏控制↓*/
//(function(){
//  var mainRight = document.getElementById("main-right");
//  var contentDiv = document.getElementById("css_contentDiv");
//  var myPushButton = document.createElement("div");
//  mainRight.style.width = '0px';
//  contentDiv.style.marginRight = '10px';
//  mainRight.appendChild(myPushButton);
//  myPushButton.className = 'myPushButton';
//  myPushButton.onclick = function(){
//      if(mainRight.style.width == '222px'){
//          mainRight.style.width = '0px';
//          contentDiv.style.marginRight = '10px';
//          myPushButton.style.right = '0px';           
//          myPushButton.style.backgroundPosition = '-376px 350px'  
//      }else{
//          mainRight.style.width = '222px';
//          contentDiv.style.marginRight = '222px';
//          myPushButton.style.right = '215px';
//          myPushButton.style.backgroundPosition = '-360px 350px';
//          $(".myPushButton").removeClass("rightBoxBg");
//          
//  
//      }
//  }
//  
//})()
/*首页框架右边栏控制↑*/


/*控制菜单默认选中项↓*/
$(document).ready(function(e) {
    var menuli = $(".menuUlHeight li a");
    var myunit = $("#levelmenu .unit h5");
    var styleTitle = $(".addressBar").length > 0 ? $(".addressBar").html().replace(/[^\u4e00-\u9fa5]/gi, "") : null;
    var a = 0;

    if (styleTitle !== null) {
        function myunitmenu() {

            if (myunit[a] != null) {
                if (styleTitle.indexOf(myunit[a].innerHTML.replace(/[^\u4e00-\u9fa5]/gi, "")) >= 0) {
                    myunit[a].parentNode.parentNode.className = 'unit current';
                    $(".loseBanner").html(myunit[a].innerHTML.replace(/[^\u4e00-\u9fa5]/gi, ""));
                    $(".loseBanner").addClass("homeBanner").removeClass("loseBanner").css("margin-left", "4px").css("visibility", "inherit");
                    $(".homeBanner").eq(0).addClass("loseBanner").removeClass("homeBanner").css("margin-left", "12px").css("visibility", "inherit");
                } else {
                    a++
                    myunitmenu()
                }
            }
        }
        myunitmenu()
    }

    if (styleTitle !== null) {
        function levelmenu() {
            if (menuli[a] != null) {
                if (styleTitle.indexOf(menuli[a].innerHTML.replace(/[^\u4e00-\u9fa5]/gi, "")) >= 0) {
                    menuli[a].parentNode.style.background = '#0099ff';
                    menuli[a].parentNode.style.color = '#ffffff';
                    menuli[a].className = 'FFF-a';
                    menuli[a].parentNode.parentNode.parentNode.className = 'unit current';
                    $(".homeBanner").html(menuli[a].innerHTML);
                    $(".homeBanner").addClass("homeBanner").removeClass("loseBanner").css("margin-left", "4px").css("visibility", "inherit");
                    $(".loseBanner").eq(0).addClass("loseBanner").removeClass("homeBanner").css("margin-left", "12px").css("visibility", "inherit");
                } else {
                    a++
                    levelmenu()
                }
            }
        }
        levelmenu()
    }

});

/*控制菜单默认选中项↑*/
//alert()方法代替,icon名称对应[js\artDialog\skins\icons\...]
function dialog_alert(param, msgType) {
    var iconType = "warning";
    var title = '提示';
    var time = 20;
    if ("0" == msgType) { //success
        iconType = "succeed";
        time = 3;
    } else if ("-1" == msgType) { //error
        iconType = "error";
    } else if ("1" == msgType) { //error
        iconType = "face-smile";
        time = 3;
    }
    $.dialog({
        id: 'N3690',
        icon: iconType,
        content: param,
        title: title,
        width: '200px',
        lock: true,
        //time: time,
        ok: function() {}
    });
}

function dialog_confirmled(content, fun) {
    $.dialog({
        id: 'N3690',
        width: '200px',
        title: true,
        title: '提示',
        lock: true,
        fixed: true,
        icon: "question",
        content: content,
        dblclickHide: false,
        button: [{
            name: '确定',
            callback: fun,
            focus: true
        }, {
            name: '取消',
            focus: true
        }]
    });
}

/*右侧栏激活动画*/
function rightFlash(i) {
    $(i).click(function(e) {
        var xx = e.originalEvent.x || e.originalEvent.layerX || 0;
        var yy = e.originalEvent.y || e.originalEvent.layerY || 0;
        var myWidth = document.body.offsetWidth;
        $('body').append("<div class='starFlash'></div>");
        var myStarFlash = $(".starFlash");
        myStarFlash.css("top", yy + "px").css("left", xx + "px");
        $(".starFlash").css("top", yy - 2 + "px").css("left", xx - 2 + "px").css("width", "10px").css("height", "10px");
        $(".starFlash").animate({
            left: xx + 200 + "px",
            top: yy - 150 + "px",
            width: '150px',
            height: '150px'
        }, 200);
        $(".starFlash").animate({
            left: myWidth + 20 + "px",
            top: yy + "px",
            width: '10px',
            height: '10px'
        }, 400);
        $(".myPushButton").addClass("rightBoxBg");

    });
}

/*弥补IE不支持选择器，Class调用
$(this).ready(function(e) {
    $(".-frame > .content .unit").eq(0).addClass("unit1");
});
*/

/*翻页数字超出处理*/
$(this).ready(function(e) {
    var i = $(".pageJump .numbgs").length != 0 ? $(".pageJump .numbgs").html().length : null;
    if (i >= 3) {
        var l = $(".pageJump .numbg");
        var f = $(".pageJump .numbgs");
        l.addClass("numbgg");
        f.addClass("numbgss");
    } else {}
});

/*移动页尾到内容最底部，设置图标页，页尾移动到最低。*/
/*$(document).ready(function(e) {
     $(".-luster .content > .foot").appendTo($("#css_contentDiv .container"));   
     var myDesktop = $(".desktop");
     var myFoot = $(".foot");
     var myWidth = $(document).width();
     if(myDesktop.length !==0){
        myFoot.css("position","absolute").css("bottom","5px").css("width",myWidth-190+'px');    
        }else{
    }
    $(".-luster .content #css_contentDiv .container .foot").prev(br)
})*/
